package com.gitee.minimalismstyle.fresh.common.core.config

import com.gitee.minimalismstyle.fresh.common.core.domain.Global
import com.gitee.minimalismstyle.fresh.common.core.domain.SnowflakeIdWorker
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import javax.annotation.PostConstruct

@Configuration(proxyBeanMethods = false)
class FreshConfig(val freshProperties: FreshProperties) {

    @PostConstruct
    fun initGlobal(){
        Global.isDebug = freshProperties.isDebug
    }

    @Bean
    fun getSnowflakeIdWorker(): SnowflakeIdWorker {
        return SnowflakeIdWorker(freshProperties.snowflake.workerId, freshProperties.snowflake.datacenterId)
    }
}